package com.happy_hao.msg.controller;

import com.happy_hao.msg.common.Result;
import com.happy_hao.msg.dto.TemplateRequest;
import com.happy_hao.msg.service.TemplateService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/msg/template")
public class TemplateController {

    @Resource
    private TemplateService templateService;

    @PutMapping("/addTemplate")
    public Result addTemplate(@Valid @RequestBody TemplateRequest templateRequest){
        return templateService.addTemplate(templateRequest);
    }

    @GetMapping("/getAllTemplate")
    public Result getAllTemplate(){
        return templateService.getAllTemplate();
    }

    @DeleteMapping("/deleteTemplate")
    public Result deleteTemplate(@RequestParam("title") String title){
        return templateService.deleteTemplate(title);
    }

    @RequestMapping("/updateTemplate")
    public Result updateTemplate(@Valid @RequestBody TemplateRequest templateRequest){
        return templateService.updateTemplate(templateRequest);
    }

}
